<!DOCTYPE html>
<html>
<head>
  <title>RequestSenderProxy.java</title>
  <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
  <link rel='stylesheet' type='text/css' href='../../../../../coverage.css'/>
  <link rel='shortcut icon' type='image/png' href='../../../../../logo.png'/>
  <script type='text/javascript' src='../../../../../coverage.js'></script>
  <script type='text/javascript' src='../../../../../prettify.js'></script>
</head>
<body onload='prettyPrint()'>
  <table cellpadding='0' cellspacing='1'>
    <caption>igraph_client_java/src/main/java/com/taobao/igraph/client/core/RequestSenderProxy.java</caption>
    <tr>
      <td class='line'>1</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>package com.taobao.igraph.client.core;</pre></td>
    </tr>
    <tr><td class='line'></td><td colspan='2'>&nbsp;</td></tr>
    <tr>
      <td class='line'></td><td>&nbsp;</td>
      <td><pre class='imports prettyprint' onclick='showHideLines(this)'><div>import com.ning.http.client.AsyncHttpClient;
import com.taobao.igraph.client.common.IGraphServerException;
import com.taobao.igraph.client.core.RequestContext;
import com.taobao.eagleeye.EagleEye;
import com.taobao.eagleeye.EagleEyeRequestTracer;
</div><span>import ...</span></pre></td>
    </tr>
    <tr><td class='line'></td><td colspan='2'>&nbsp;</td></tr>
    <tr>
      <td class='line'>9</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>public class RequestSenderProxy extends IGraphRequester {</pre></td>
    </tr>
    <tr>
      <td class='line'>10</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    private final static String EAGLE_HEADER_TRACEID = EagleEyeRequestTracer.EAGLEEYE_TRACEID_HEADER_KEY;</pre></td>
    </tr>
    <tr>
      <td class='line'>11</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    private final static String EAGLE_HEADER_RPCID = EagleEyeRequestTracer.EAGLEEYE_RPCID_HEADER_KEY;</pre></td>
    </tr>
    <tr>
      <td class='line'>12</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    private final static String EAGLE_HEADER_UDATA = "EagleEye-UserData";</pre></td>
    </tr>
    <tr><td class='line'></td><td colspan='2'>&nbsp;</td></tr>
    <tr>
      <td class='line'>14</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l14s0'>    public RequestSenderProxy() {</pre></td>
    </tr>
    <tr>
      <td class='line'>15</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l15s0'>    }</pre></td>
    </tr>
    <tr><td class='line'></td><td colspan='2'>&nbsp;</td></tr>
    <tr>
      <td class='line'>17</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    @Override</pre></td>
    </tr>
    <tr>
      <td class='line'>18</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    protected byte[] sendRequest(RequestContext requestContext, RequestType requestType) throws IGraphServerException {</pre></td>
    </tr>
    <tr>
      <td class='line'>19</td><td>&nbsp;</td>
      <td><pre class='comment'>        // EagleEye ignores these calls when current rpc context is null</pre></td>
    </tr>
    <tr>
      <td class='line'>20</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l20s0'>        EagleEye.rpcClientSend();</pre></td>
    </tr>
    <tr>
      <td class='line'>21</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l21s0'>        EagleEye.requestSize(requestContext.getRequestContent().length());</pre></td>
    </tr>
    <tr>
      <td class='line'>22</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l22s0'>        EagleEye.remoteIp(requestContext.getServerIP());</pre></td>
    </tr>
    <tr>
      <td class='line'>23</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l23s0'>        byte[] resp = null;</pre></td>
    </tr>
    <tr>
      <td class='line'>24</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>        try {</pre></td>
    </tr>
    <tr>
      <td class='line'>25</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l25s0'>            resp = super.sendRequest(requestContext, requestType);</pre></td>
    </tr>
    <tr>
      <td class='line'>26</td><td class='count'>0</td>
      <td><pre class='prettyprint uncovered' id='l26s0'>        } catch (IGraphServerException e) {</pre></td>
    </tr>
    <tr>
      <td class='line'>27</td><td class='count'>0</td>
      <td><pre class='prettyprint uncovered' id='l27s0'>            requestContext.endRpc(false);</pre></td>
    </tr>
    <tr>
      <td class='line'>28</td><td class='count'>0</td>
      <td><pre class='prettyprint uncovered' id='l28s0'>            throw e;</pre></td>
    </tr>
    <tr>
      <td class='line'>29</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l29s0'>        }</pre></td>
    </tr>
    <tr>
      <td class='line'>30</td><td class='count'>1</td>
      <td><pre class='prettyprint jmp'>        <span id='l30s0' title='Executions: 1' class='covered'>if (resp == null)</span> {</pre></td>
    </tr>
    <tr>
      <td class='line'>31</td><td class='count'>0</td>
      <td><pre class='prettyprint uncovered' id='l31s0'>            requestContext.endRpc(false);</pre></td>
    </tr>
    <tr>
      <td class='line'>32</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>        } else {</pre></td>
    </tr>
    <tr>
      <td class='line'>33</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l33s0'>            EagleEye.responseSize(resp.length);</pre></td>
    </tr>
    <tr>
      <td class='line'>34</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l34s0'>            requestContext.endRpc(true);</pre></td>
    </tr>
    <tr>
      <td class='line'>35</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>        }</pre></td>
    </tr>
    <tr>
      <td class='line'>36</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l36s0'>        return resp;</pre></td>
    </tr>
    <tr>
      <td class='line'>37</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    }</pre></td>
    </tr>
    <tr><td class='line'></td><td colspan='2'>&nbsp;</td></tr>
    <tr>
      <td class='line'>39</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    @Override</pre></td>
    </tr>
    <tr>
      <td class='line'>40</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    protected void appendHeaders(RequestContext requestContext,  AsyncHttpClient.BoundRequestBuilder request) {</pre></td>
    </tr>
    <tr>
      <td class='line'>41</td><td class='count'>1</td>
      <td><pre class='prettyprint jmp'>        <span id='l41s0' title='Executions: 1' class='covered'>if (!requestContext.isTraceInHeader())</span> <span id='l41s1' title='Executions: 0' class='uncovered'>return ;</span></pre></td>
    </tr>
    <tr>
      <td class='line'>42</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l42s0'>        String traceId = requestContext.getTraceId();</pre></td>
    </tr>
    <tr>
      <td class='line'>43</td><td class='count'>1</td>
      <td><pre class='prettyprint covered' id='l43s0'>        String rpcId = requestContext.getRpcId();</pre></td>
    </tr>
    <tr>
      <td class='line'>44</td><td class='count'>1</td>
      <td><pre class='prettyprint jmp'>        <span id='l44s0' title='Executions: 1' class='covered'>if (traceId.isEmpty()</span> || <span id='l44s1' title='Executions: 0' class='uncovered'>rpcId.isEmpty())</span> <span id='l44s2' title='Executions: 1' class='covered'>return ;</span></pre></td>
    </tr>
    <tr>
      <td class='line'>45</td><td class='count'>0</td>
      <td><pre class='prettyprint uncovered' id='l45s0'>        String udata = requestContext.getExportedUserData();</pre></td>
    </tr>
    <tr>
      <td class='line'>46</td><td class='count'>0</td>
      <td><pre class='prettyprint uncovered' id='l46s0'>        request.addHeader(EAGLE_HEADER_TRACEID, traceId);</pre></td>
    </tr>
    <tr>
      <td class='line'>47</td><td class='count'>0</td>
      <td><pre class='prettyprint uncovered' id='l47s0'>        request.addHeader(EAGLE_HEADER_RPCID, rpcId);</pre></td>
    </tr>
    <tr>
      <td class='line'>48</td><td class='count'>0</td>
      <td><pre class='prettyprint uncovered' id='l48s0'>        request.addHeader(EAGLE_HEADER_UDATA, udata);</pre></td>
    </tr>
    <tr>
      <td class='line'>49</td><td class='count'>0</td>
      <td><pre class='prettyprint uncovered' id='l49s0'>    }</pre></td>
    </tr>
    <tr>
      <td class='line'>50</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>}</pre></td>
    </tr>
  </table>
</body>
</html>
